import requests
from retrying import retry

headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"}

@retry(stop_max_attempt_number=3)
def _parse_url(url):
    print("*"*20)
    response = requests.get(url,headers=headers,timeout=3)
    assert response.status_code == 200
    return response.content.decode()

def parse_url(url):
    try:
        html_str = _parse_url(url)
    except:
        html_str = None
    return html_str

if __name__ == '__main__':
    url = "https://www.baidu.com/"
    print(parse_url(url))

"""
注意：如果要调用某py文件中的方法，该py文件不能以数字开头，且不能含有中文
"""